// pages/list/list.js
import { getMusicList } from '../../config/api'
let app = getApp()
Page({
  data: {
    list: []
  },
  onLoad: function (options) {
    let { id, title } = options
    wx.setNavigationBarTitle({
      title: title
    })
    this.initData(id)
  },
  initData(id){
    getMusicList(id,res=>{
      this.setData({
        list: res.data.playlist.tracks
      })
      app.globalData.playList = res.data.playlist.tracks
    })
  },
  goToDetail(e){
    let {id} = e.currentTarget.dataset
    wx.navigateTo({
      url: `/pages/detail/detail?id=${id}`
    })
  }
})